package cn.demomaster.quickui_sample.ui.fragment.component;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.demomaster.quickcompat.widget.button.QuickButton;
import com.demomaster.quickcompat.widget.popup.QuickPopupWindow;

import cn.demomaster.quickrouter.fragment.QuickFragment;
import cn.demomaster.quickui.annotation.ActivityPager;
import cn.demomaster.quickui.annotation.ResType;
import cn.demomaster.quickui_sample.R;

/**
 * Squirrel桓
 * 2018/8/25
 */
@ActivityPager(name = "PopUp", preViewClass = TextView.class, resType = ResType.Custome)
public class PopUpFragment extends QuickFragment {

    @Nullable
    @Override
    public View onGenerateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View mView = inflater.inflate(R.layout.fragment_layout_popup, null);
        return mView;
    }
    QuickButton btn_01;
    public void initView(View rootView) {
        btn_01 = rootView.findViewById(R.id.btn_01);
        btn_01.setOnClickListener(view -> showPop());
    }

    private QuickPopupWindow pop = null;

    private void showPop() {
        View view = getLayoutInflater().inflate(R.layout.item_popup_common,
                null);
        QuickPopupWindow.Builder builder = new QuickPopupWindow.Builder(getContext()).setContentView(R.layout.item_popup_common).setContentView(view);
        pop = builder.create();
        pop.setFocusable(true);
        pop.setOutsideTouchable(true);
        //pop.showAtLocation(btn_01, Gravity.BOTTOM, 0, 0);
        pop.showAsDropDown(view);
        /*startAnimation(AnimationUtils.loadAnimation(getThemeActivity(),
                R.anim.bottom_up));*/
    }

}